<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    for(var i=0;i<3;i++){
        var myname="myname"+i;
        myname=i;
        console.log(myname,'myname');
    }
    console.log(myname,'myname');

    var vars={}; //批量定义
for(var i=0;i<5;i++){
    var varName='name-'+i;  //动态定义变量名
    vars[varName]='value-'+i;  //动态赋值
}
console.log(vars);
</script>
</html>